import * as BABYLON from '@babylonjs/core';
import * as GUI from '@babylonjs/gui';
import { AbstractDevice } from '../AbstractDevice';
import { ArrowBuiler } from './controls/ArrowBuiler';
import { BabylonScene2d } from './BabylonScene2d';
import { TWcsSceneDevice3d, TWcsSceneDevice2d } from '../../models';
import { BabylonScene } from '../BabylonScene';
import { ClassHelper } from '../../ClassHelper';
import { StandardDevice2d } from './devices';
import { BaseDeviceControl2d } from './devices/BaseDeviceControl2d';

export class BabylonDevice2d extends AbstractDevice<BaseDeviceControl2d, TWcsSceneDevice2d> {
  public radius: number = 10;
  constructor(scene: BabylonScene, data: TWcsSceneDevice2d) {
    super(scene, data);
    // this.scene.scene.debugLayer.show();
  }

  public render(): void {
  }

  public contains(sceneX: number, sceneY: number): boolean {
    return this.deviceObject != undefined && this.deviceObject.contains(sceneX, sceneY);
  }

  protected setupDeviceObject(): BaseDeviceControl2d | undefined {
    if(this.data.controlType) {
      var device = ClassHelper.createInstance<BaseDeviceControl2d>(this.data.controlType, this.data);
      device?.init();
      return device || undefined;
    }

    return undefined;
  }

  protected setupAnimations(): Map<string, BABYLON.AnimationGroup> {
    return new Map<string, BABYLON.AnimationGroup>();
  }
}
